<!DOCTYPE html>
<html>
	<head>
	<meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title></title>
    <script src="../js/mui.min.js"></script>
    <link href="../css/mui.min.css" rel="stylesheet"/>
    <link href="../style/fjol_style.css" rel="stylesheet" />
    <link rel="stylesheet" type="text/css" href="../style/xol_style.css"/>
    <link href="../css/iosSelect.css" rel="stylesheet" />
    <link href="../css/mui.picker.min.css" rel="stylesheet" />
    
    <script type="text/javascript" charset="utf-8">
      	mui.init();
    	
   		
    </script>
	</head>
	<style>
		.mui-input-row label~input, .mui-input-row label~select, .mui-input-row label~textarea{
			margin-right: 10px;
			width: 50%;
		}
		.mui-input-row .mui-input-clear~.mui-icon-clear, .mui-input-row .mui-input-password~.mui-icon-eye, .mui-input-row .mui-input-speech~.mui-icon-speech{
			width: 30px;
		}
	</style>
	<body>
		<header class="mui-bar mui-bar-nav newbgRed">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
		    <h1 class="mui-title">发布房源</h1>
		</header>
		<div class="mui-content">
		    <div class="mui-scroll-wrapper" style="bottom: 40px; top: 40px;">
		        <div class="mui-scroll">
		            <!--这里放置真实显示的DOM内容-->
		            <p class="mt10">第二步：房源和楼盘信息</p>
		            <ul class="mui-table-view mt10">
	                    <li class="mui-table-view-cell">
	                        <a class="mui-navigate-right" id="searchBuilding">
	                     楼盘名称
	                    		<span class="mui-pull-right mr10"></span>
	                		</a>
	                    </li>
	                </ul>
		            
		            <p class="mt10">房源信息</p>
		            <div class="mui-input-group mt5">
					    
					    <div class="mui-input-row" style="padding-right: 10px;">
					        <label>面积</label>
					        <button type="button" class="mui-btn-green mui-btn-outlined mui-pull-right p0 mt10 f08">平方</button>
					        <input type="number" id="square" class="mui-input-clear mui-text-right mui-pull-right" style="width: 55%;" placeholder="" value="">
					    </div>
					    <div class="mui-input-row" id="houseType">
					        <label>户型</label>
					        <input type="text" class="mui-text-right" placeholder="" value="1室0厅0卫">
					    </div>
					    <div class="mui-input-row">
					        <label>朝向</label>
					        <input type="text" id="orientationsName" class="mui-input-clear mui-text-right" value="东">
					    </div>
					    <div class="mui-input-row">
					        <label>楼层</label>
					        <input type="text" id="floorNumber" class="mui-input-clear mui-text-right" value="">
					    </div>
					    <div class="mui-input-row">
					        <label>年代</label>
					        <input type="number" id="buildDate" class="mui-input-clear mui-text-right mui-pull-right" style="width: 55%;" placeholder="" value=""/>
					    </div>
					</div>
					
		        </div>
		    </div>
		    <nav class="mui-bar mui-bar-tab" style="background: none; box-shadow: none;">
		    	<button type="button" class="mui-btn newbgRed colorWhite mui-btn-block pct80 mauto borderRadius6" id="submitIssue">确认提交</button>
		    </nav>
		</div>
		<script src="../css/iosSelect.js"></script>
		<script src="../js/md5.js"></script>
		<script src="../js/common.util.js"></script>
		<script src="../js/network.js"></script>
		<script src="../js/enum.util.js"></script>
		<script src="../js/mui.picker.min.js"></script>
		<script src="../js/mui.poppicker.js"></script>
		<script src="../js/xzx.open.js"></script>
		<script>
			mui('.mui-scroll-wrapper').scroll({
			deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
		});
		
		mui.plusReady(function(){
			var wv = plus.webview.currentWebview();
			var _type = wv.type;		//页面类型
			var buildingId=null;
			var bedRoomNumber=1,livingRoomNumber=0,toiletNumber=0;
			
			var houseType = document.querySelector('#houseType');//房型
			
			var bedRoomData = [{
				'id':'1',
				'value':'1室'
			}];
			var livingRoomData = [{
				'id':'0',
				'value':'厅'
			}];
			var toiletRoomData = [{
				'id':'0',
				'value':'卫'
			}];
			for (var i=0; i<10; i++) {
				bedRoomData[i]={
					'id':i+1,
					'value':i+1+'室'
				};
				if(i==9){
					bedRoomData[i]={
						'id':i+1,
						'value':'10室及以上'
					}
				}
			}
			for (var i=0; i<=10; i++) {
				livingRoomData[i]={
					'id':i,
					'value':i+'厅'
				};
				if(i==10){
					livingRoomData[i]={
						'id':i,
						'value':'10厅及以上'
					}
				}
				toiletRoomData[i]={
					'id':i,
					'value':i+'卫'
				};
				if(i==10){
					toiletRoomData[i]={
						'id':i,
						'value':'10卫及以上'
					}
				}
			}
			
			houseType.addEventListener('tap', function () {
				
		    var sanguoSelect = new IosSelect(3, 
		        [bedRoomData,livingRoomData, toiletRoomData],
		        {
		            title: '选择户型',
		            itemHeight: 35,
		            callback: function (selectOneObj, selectTwoObj, selectThreeObj) {
		                bedRoomNumber = selectOneObj.value;
		                livingRoomNumber = selectTwoObj.value;
		                toiletNumber = selectThreeObj.value;
		                document.querySelector('#houseType input').value = selectOneObj.value+selectTwoObj.value+selectThreeObj.value;
		            }
				});
			});
			//朝向
			var orientationsName = '东';
			var orientationsEnumValue = 1;
			var isContent = false;
			document.querySelector('#orientationsName').value = orientationsName;
			document.querySelector('#orientationsName').addEventListener('tap',function(){
				var orientationsPicker = new mui.PopPicker();
				var orientationsArr = new Array();
				var getorientationsType = enumUtils.getEnumDataByType('houseOrientations');
				for (i in getorientationsType) {
					orientationsArr[i]={
						text:getorientationsType[i].name,
						value:getorientationsType[i].value
					}
				}
				orientationsPicker.setData(orientationsArr);
				orientationsPicker.pickers[0].setSelectedValue('forth', 2000);
				orientationsPicker.show(function(SelectedItem) {
					orientationsName = SelectedItem[0].text;
					orientationsEnumValue = SelectedItem[0].value;
					document.querySelector('#orientationsName').value = orientationsName;
				});
			});
			//楼层
			var floorsNumber = [{
				text:'共1层',
				value:'1'
			}];
			var floors = [{
				text:'第1层',
				value:'1'
			}];
			for (var i=0; i<35; i++) {
				floorsNumber[i] = {
					text:'共'+(i+1)+'层',
					value:i
				};
				
				floorsNumber[i].children = new Array();
				for(var j=0; j<=i; j++){
					floorsNumber[i].children[j] = {
						text:'第'+(j+1)+'层',
						value:i+j
					};
				}
			}
			
			document.querySelector('#floorNumber').value = floorsNumber[0].children[0].text +' '+ floorsNumber[0].text;
			document.querySelector('#floorNumber').addEventListener('tap',function(){
				var floorsPicker = new mui.PopPicker({
					layer: 2
				});
				floorsPicker.setData(floorsNumber);
				floorsPicker.pickers[0].setSelectedValue('forth', 2000);
				floorsPicker.show(function(SelectedItem) {
					document.querySelector('#floorNumber').value = SelectedItem[1].text+' '+SelectedItem[0].text;
				});
			});
			//年代
			var buildDate = [{
				text:'2017',
				value:'2017'
			}];
			var oDate = new Date();
//			console.log(oDate.getFullYear());
			for (var i=oDate.getFullYear(),j=0; j<70; i--,j++) {
				buildDate[j] = {
					text:i,
					value:i
				}
			}
			document.querySelector('#buildDate').value = buildDate[0].text;
			document.querySelector('#buildDate').addEventListener('tap',function(){
				var buildDatePicker = new mui.PopPicker();
				buildDatePicker.setData(buildDate);
				buildDatePicker.pickers[0].setSelectedValue('forth', 2000);
				buildDatePicker.show(function(SelectedItem) {
					document.querySelector('#buildDate').value = SelectedItem[0].text;
				});
			});
			document.addEventListener('getBuilding',function(event){
				buildingId = event.detail.buildingId;
				var buildingName = event.detail.buildingName;
//				console.log(buildingName);
				document.querySelector('#searchBuilding span').innerHTML = buildingName;
			});
			
			document.querySelector('#submitIssue').addEventListener('tap',function(){
				
				mui.toast('您的房源数据已经提交，我们将第一时间与您联系，请耐心等待');
				var parentPage =  plus.webview.getWebviewById('fj_house_issue');
				
				setTimeout(function(){
							mui.fire(parentPage,'muiBack');
						},1500);
			});
			
		switch(_type){
			case 1:
			  document.querySelector('.mui-title').innerHTML = '发布房源';
			  
			  break;
			case 2:
			  document.querySelector('.mui-title').innerHTML = '发布出租房源';
			  
			  break;
			case 3:
			  document.querySelector('.mui-title').innerHTML = '我要估价';
			  
			  break;
		}
		
		
		document.querySelector('#searchBuilding').addEventListener('tap',function(){
			openWindowWithPage('search_building',{
//				parentId:'houseIssue',
				_type:_type			//1、发布房源；2、租房；3、房屋估价
			})
			
		});
		
		});
		</script>
	</body>
</html>
